package com.global.college.ui.presenter;

import android.content.Context;

import com.global.college.api.ProgressSubscriber;
import com.global.college.base.BasePresenter;
import com.global.college.data.net.MyTrainListBean;
import com.global.college.ui.interfaces.ITrainingView;

/**
 * 训练营
 */
public class TrainingPresenter extends BasePresenter {

    private ITrainingView mITrainingView;

    public TrainingPresenter(Context context) {
        super(context);
    }

    public void setTrainingView(ITrainingView trainingView){
        mITrainingView = trainingView;
    }

    /**
     * 训练营列表
     * @param
     */
    public void getTrainingList(int pageNum, int pageSize, int type){
        mRequestClient.getTraningList( pageNum,  pageSize,  type).subscribe(new ProgressSubscriber<MyTrainListBean>(mContext,true) {
            @Override
            public void onNext(MyTrainListBean object) {
                if(null != mITrainingView){
                    mITrainingView.onGetTrainingListSuccess(object);
                }
            }

            @Override
            public void onError(Throwable e) {
                super.onError(e);
                if(null != mITrainingView){
                    mITrainingView.onGetTrainingListFail(e.getMessage());
                }
            }
        });
    }

    /**
     * 训练营详情
     * @param
     */
    public void getTrainDetail(String trainId, String userId){
        mRequestClient.getTrainDetail( trainId,  userId).subscribe(new ProgressSubscriber<Object>(mContext,true) {
            @Override
            public void onNext(Object smsModel) {
                if(null != mITrainingView){
                    mITrainingView.onGetTrainingDetailSuccess(smsModel);
                }
            }
            @Override
            public void onError(Throwable e) {
                super.onError(e);
                if(null != mITrainingView){
                    mITrainingView.onGetTrainingDetailFail(e.getMessage());
                }
            }
        });
    }

}
